from django.urls import path
from . import views
from rest_framework_jwt.views import obtain_jwt_token
from apps.meiduo_admin.views.login import admin_obtain_jwt_token
from apps.meiduo_admin.views import home, group, admin, order
from apps.meiduo_admin.views import user
from apps.meiduo_admin.views import images
from rest_framework.routers import DefaultRouter
from apps.meiduo_admin.views import sku
from apps.meiduo_admin.views import permission

urlpatterns = [
    # meiduo_admin/authorizations/
    # meiduo_admin/ 已经在工程的 urls里匹配过了
    # path('authorizations/', obtain_jwt_token),
    path('authorizations/', admin_obtain_jwt_token),

    # 获取日活的数量
    path('statistical/day_active/', home.DailyActiveView.as_view()),
    # 日下单量
    path('statistical/day_orders/', home.DailyOrderCountAPIView.as_view()),
    # 月增用户
    path('statistical/month_increment/', home.MonthAPIView.as_view()),
    # 用户总量统计
    path('statistical/total_count/', home.TotleCountAPIView.as_view()),
    # 日增用户
    path('statistical/day_increment/', home.DayIncrementAPIView.as_view()),

    # 作业订单状态
    path('orders/<pk>/status/', order.OrderStatusAPIView.as_view()),

    # user管理
    # path('users/', user.User2APIView.as_view()),
    path('users/', user.UserAPIView.as_view()),

    # 新增图片中,获取sku列表路由
    path('skus/simple/', images.SKUSimpleListAPIView.as_view()),

    # 获取三级分类数据
    path('skus/categories/', sku.ThreeCategoryAPIView.as_view()),

    # 获取所有的spu数据
    path('goods/simple/', sku.SPUListAPIView.as_view()),

    # 根据spu_id 获取规格和规格选项
    path('goods/<int:pk>/specs/', sku.SPUSpecsAPIView.as_view()),

    # 获取所有权限
    path('permission/simple/', group.AllPermissionListAPIView.as_view()),

    # 获取所有组
    path('permission/groups/simple/', admin.SimpleGroupListAPIView.as_view()),
]

# 创建router
router = DefaultRouter()
# 注册路由
# prefix,        路由
# viewset,      视图集
# basename=None 路由别名
router.register(r'skus/images', images.ImageModelViewSet, basename='images')
# 将router自动生成的路由追加到urlpatterns
urlpatterns += router.urls

# sku的路由
router.register(r'skus', sku.SKUModelViewSet, basename='sku')
# 3.将router自动生成的路由追加到urlpatterns
urlpatterns += router.urls

# 权限路由
# sku的路由
router.register(r'permission/perms', permission.PermissionModelViewSet, basename='perms')
# 将router自动生成的路由追加到urlpatterns
urlpatterns += router.urls

# 作业订单管理
router.register('orders', order.OrdersView,basename='orders')
# 将router生成的路由追加到urlpatterns中
urlpatterns += router.urls
